<template>
	<view class="info">
		<template v-if="newsList.length>0">
			<view v-for="(item,index) in newsList" :key="item.id" class="info-item" @click="pushInfoDetail(item.id)">

				<view class="imgItem">
					<image class="img" :src="item.img_url" mode=""></image>
				</view>
				<view class="item-text">
					<text>{{item.title}}</text>
					<view class="item-text-btm">
						<text>发表时间：{{item.add_time?item.add_time.slice(0,10):''}}</text>
						<text style="margin-left: 32rpx;">浏览：{{item.click}}</text>
					</view>
				</view>
			</view>
		</template>


	</view>
</template>

<script>
	export default {
		data() {
			return {
				newsList: []
			};
		},
		onLoad() {
			this.getNewList()
		},
		methods: {
			async getNewList() {
				this.newsList = await this.$myRequest({
					url: '/api/getnewslist'
				})

			},
			pushInfoDetail(id) {
				uni.navigateTo({
					url: '/pages/InfoDetail/InfoDetail?id=' + id
				})
			}
		}
	}
</script>

<style lang="scss" scoped>
	.info {
		width: 750rpx;

		.info-item {
			width: 750rpx;
			height: 186rpx;
			display: flex;
			padding: 10rpx;
			border-bottom: 4rpx solid #d9837d;
			box-sizing: border-box;
			justify-content: space-between;

			.imgItem {
				width: 220rpx !important;
				height: 164rpx !important;
				box-sizing: border-box;
				// overflow: hidden;

				.img {
					width: 220rpx;

				}
			}


			.item-text {
				width: 530rpx;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				box-sizing: border-box;
				padding-right: 10rpx;
				padding-left: 6rpx;



				text {
					display: inline-block;

				}

				.item-text-btm {
					font-size: 26rpx;
				}
			}
		}
	}
</style>